﻿@{
    Layout = "_LayoutPhone";
}

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<link rel="apple-touch-icon" href="~/GoTRI/img/favicon-apple.png">
<link rel="icon" href="~/GoTRI/img/favicon.png">
<title>添加客户</title>

<!-- Material design icons CSS -->
<link rel="stylesheet" href="~/GoTRI/vendor/materializeicon/material-icons.css">

<!-- aniamte CSS -->
<link rel="stylesheet" href="~/GoTRI/vendor/animatecss/animate.css">

<!-- swiper carousel CSS -->
<link rel="stylesheet" href="~/GoTRI/vendor/swiper/css/swiper.min.css">

<!-- daterange CSS -->
<link rel="stylesheet" href="~/GoTRI/vendor/bootstrap-daterangepicker-master/daterangepicker.css">

<!-- footable CSS -->
<link rel="stylesheet" href="~/GoTRI/vendor/footable-bootstrap/css/footable.bootstrap.min.css">

<!-- jvector map CSS -->
<link rel="stylesheet" href="~/GoTRI/vendor/jquery-jvectormap/jquery-jvectormap-2.0.3.css">

<!-- app CSS -->
<link id="theme" rel="stylesheet" href="~/GoTRI/css/purplesidebar.css" type="text/css">

<script src="~/GoTRI/js/jquery-3.2.1.min.js"></script>
<script src="~/GoTRI/js/popper.min.js"></script>

<!-- Cookie jquery file -->
<script src="~/GoTRI/vendor/cookie/jquery.cookie.js"></script>

<!-- sparklines chart jquery file -->
<script src="~/GoTRI/vendor/sparklines/jquery.sparkline.min.js"></script>

<!-- Circular progress gauge jquery file -->
<script src="~/GoTRI/vendor/circle-progress/circle-progress.min.js"></script>

<!-- Swiper carousel jquery file -->
<script src="~/GoTRI/vendor/swiper/js/swiper.min.js"></script>

<!-- Chart js jquery file -->
<script src="~/GoTRI/vendor/chartjs/Chart.bundle.min.js"></script>
<script src="~/GoTRI/vendor/chartjs/utils.js"></script>

<!-- Footable jquery file -->
<script src="~/GoTRI/vendor/footable-bootstrap/js/footable.min.js"></script>

<!-- datepicker jquery file -->
<script src="~/GoTRI/vendor/bootstrap-daterangepicker-master/moment.js"></script>
<script src="~/GoTRI/vendor/bootstrap-daterangepicker-master/daterangepicker.js"></script>

<!-- jVector map jquery file -->
<script src="~/GoTRI/vendor/jquery-jvectormap/jquery-jvectormap.js"></script>
<script src="~/GoTRI/vendor/jquery-jvectormap/jquery-jvectormap-world-mill-en.js"></script>

<!-- circular progress file -->
<script src="~/GoTRI/vendor/circle-progress/circle-progress.min.js"></script>

<!-- Application main common jquery file -->
<script src="~/GoTRI/js/main.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-sweetalert/sweetalert.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/themes/global/js/components/bootstrap-sweetalert.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/js/examples/components/advanced/bootbox-sweetalert.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/js/tsk/sweetalert.min.js"></script>
<script>
    $(document).ready(function () {
        var LianXiFangShi = getQuery("LianXiFangShi");
        var Id = getQuery("Id");
        $("#LianXiFangShiPanDuan").val(Id);
        if (LianXiFangShi != null && LianXiFangShi != "") {
            $("#txt_ShouJiHaoMa").val(LianXiFangShi);
            $('#txt_ShouJiHaoMa').attr('disabled', "true");
        }
        xianqu()
    });

    function getQuery(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]); return null;
    }

    function Submit() {
        var XingMing = $("#txt_XingMing").val();
        var LianXiDianHua = $("#txt_ShouJiHaoMa").val();
        var NianLing = $("#txt_NianLing").val();
        var XingBie = $("#dl_XingBie").find("option:selected").val();

        var xiaoqu = $("#i_slt_xiaoqu").find("option:selected").val();

        var YiXiangDengJi = $("#dl_YiXiangDengJi").find("option:selected").val();
        var YiXiangHuXing = $("#txt_YiXiangHuXing").val();
        var YiXiangMianJi = $("#txt_YiXiangMianJi").val();
        var YiXiangDanJia = $("#txt_YiXiangDanJia").val();
        var YiXiangZongJia = $("#txt_YiXiangZongJia").val();
        var BeiZhu = $("#txt_KeHuBeiZhu").val();
        var LianXiFangShiPanDuan = $("#LianXiFangShiPanDuan").val();
        if ($.trim(XingMing).length == 0) {
            swal("失败提示!", "请填写姓名!", "error");
            return;
        } if (!(/^1[3456789]\d{9}$/.test(LianXiDianHua))) {
            swal("失败提示!", "请输入正确的手机号码!", "error");
            return;
        }
        $("#nb").removeAttr("hidden");
        $("#btn_TiJiao").attr("disabled", "disabled");
        $.ajax({
            type: "POST",
            url: "../PhoneKeHu/AddKeHu",
            cache: false,  //禁用缓存
            data: { "XingMing": "" + XingMing + "", "ShouJiHaoMa": "" + LianXiDianHua + "", "NianLing": "" + NianLing + "", "XingBie": "" + XingBie + "", "YiXiangDengJi": "" + YiXiangDengJi + "", "YiXiangHuXing": "" + YiXiangHuXing + "", "YiXiangMianJi": "" + YiXiangMianJi + "", "YiXiangDanJia": "" + YiXiangDanJia + "", "YiXiangZongJia": "" + YiXiangZongJia + "", "KeHuBeiZhu": "" + BeiZhu + "", "LianXiFangShiPanDuan": "" + LianXiFangShiPanDuan + "", "XiaoQu": "" + xiaoqu + "" },  //传入组装的参数
            dataType: "text",
            success: function (result) {
                //alert(result);
                $("#nb").attr("hidden", "");
                $("#btn_TiJiao").attr("disabled", false);

                //if (result == "success") {
                //    swal("成功提示!", "保存成功!", "success");
                //    setTimeout(function () { window.location.href = "My_Customer"; }, 2000);
                //} else if (result == "errorShouJi") {
                //    swal("失败提示!", "该手机号和意向小区已存在!", "error");
                //}
                ////else if (result == "error2") {
                ////    swal("失败提示!", "已存在同手机号码购买当前小区房子请完成后，重新添加客户!", "error");
                ////}
                //else {
                //    swal("失败提示!", "保存失败!", "error");
                //}


                if (result == "5") {
                    swal("成功提示!", "保存成功!", "success");
                    setTimeout(function () { window.location.href = "../PhoneKeHu/My_Customer?panduan=shouye"; }, 2000);
                } else if (result == "-2" || result == "-3")
                {
                    swal("失败提示!", "该客户已添加并未失效!", "error");
                }else {
                    swal("失败提示!", "保存失败!", "error");
                }
            }
        });
    }

    function xianqu() {
        $.ajax({
            type: "POST",
            url: "../PhoneKeHu/fanyuanliebiao",
            cache: false,  //禁用缓存
            dataType: "json",
            success: function (date) {
                var XLK = $("#i_slt_xiaoqu");
                $(date).each(function (key) {
                    var opt = $("<option></option>").text(date[key].XiaoQuMingCheng).val(date[key].Id);
                    XLK.append(opt);
                })
            }
        });
    }
</script>
<div class="container mt-4 main-container">
    <input type="text" hidden="hidden" id="LianXiFangShiPanDuan" />
    <div class="card mb-4">
        <div class="card-header border-bottom py-4 text-center">
            <br>
            <h1 class="content-color-primary mb-0 text-center font-weight-light">Enter Customer Information!</h1>
        </div>
        <div class="card-body">
            <div class="row justify-content-center">
                <div class="col-md-10 mx-auto" style="margin-bottom:-40px;">
                    <div class="row ">
                        <div class="col-lg-6 col-md-6">
                            <div class="form-group ">
                                <label>姓名<span style="color:red;">*</span></label>
                                <input type="text" id="txt_XingMing" class="form-control" placeholder="">
                            </div>
                        </div>
                        <div class="col-lg-6 col-md-6">
                            <div class="form-group ">
                                <label>联系电话<span style="color:red;">*</span></label>
                                <input type="text" id="txt_ShouJiHaoMa" class="form-control" placeholder="">
                            </div>
                        </div>
                    </div>
                    <div class="row ">
                        <div class="col-lg-6 col-md-6">
                            <div class="form-group ">
                                <label>年龄<span style="color:red;"></span></label>
                                <input type="text" id="txt_NianLing" class="form-control" placeholder="">
                            </div>
                        </div>
                        <div class="col-lg-6 col-md-6">
                            <div class="form-group ">
                                <label>性别<span style="color:red;"></span></label>
                                <select id="dl_XingBie" class="form-control"><option value="男">男</option><option value="女">女</option></select>
                            </div>
                        </div>
                    </div>
                    <div class="row ">
                        <div class="col-lg-6 col-md-6">
                            <div class="form-group ">
                                <label>意向小区<span style="color:red;"></span></label>
                                <select id="i_slt_xiaoqu" class="form-control">
                                </select>
                            </div>
                        </div>
                        <div class="col-lg-6 col-md-6">
                            <div class="form-group ">
                                <label>意向等级<span style="color:red;"></span></label>
                                <select id="dl_YiXiangDengJi" class="form-control"><option value="高">高</option><option value="中">中</option><option value="低">低</option></select>
                            </div>
                        </div>
                        <div class="col-lg-6 col-md-6">
                            <div class="form-group ">
                                <label>意向户型<span style="color:red;"></span></label>
                                <input type="email" id="txt_YiXiangHuXing" class="form-control" placeholder="">
                            </div>
                        </div>
                    </div>
                    <div class="row ">

                        <div class="col-lg-6 col-md-6">
                            <div class="form-group ">
                                <label>意向面积㎡<span style="color:red;"></span></label>
                                <input type="tel" id="txt_YiXiangMianJi" class="form-control" placeholder="">
                            </div>
                        </div>
                        <div class="col-lg-6 col-md-6">
                            <div class="form-group ">
                                <label>意向单价<span style="color:red;"></span></label>
                                <input type="email" id="txt_YiXiangDanJia" class="form-control" placeholder="">
                            </div>
                        </div>
                    </div>
                    <div class="row ">
                        <div class="col-lg-6 col-md-6">
                            <div class="form-group ">
                                <label>意向总价<span style="color:red;"></span></label>
                                <input type="tel" id="txt_YiXiangZongJia" class="form-control" placeholder="">
                            </div>
                        </div>
                        <div class="col-lg-6 col-md-6">
                            <div class="form-group ">
                                <label>备注<span style="color:red;"></span></label>
                                <textarea id="txt_KeHuBeiZhu" cols="20" rows="6" class="form-control"></textarea>
                            </div>
                        </div>
                    </div>
                    <br>
                    @*<div class="row ">
                            <div class="col-lg-12 col-md-12">
                                <div class="form-group ">
                                    <div class="custom-control custom-checkbox">
                                        <input type="checkbox" class="custom-control-input" id="agreement">
                                        <label class="custom-control-label" for="agreement">I like to recieve Annual day tickets</label>
                                    </div>
                                </div>
                            </div>
                        </div>*@
                </div>
            </div>
        </div>
        <div class="card-footer" style="text-align: center;width:100%; margin-bottom:70px;">
            <button class="btn btn-success float-right" onclick="Submit();" id="btn_TiJiao" style="width:100%">提交</button>
        </div>
    </div>
</div>
<div style="margin-bottom: 50px;padding-bottom:1px"></div>
